package com.jxmcloud.business.cut.service.impl.database;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jxmcloud.business.cut.mapper.database.IUserFlowInfoDBMapper;
import com.jxmcloud.business.cut.model.database.DBUserFlowInfo;
import com.jxmcloud.business.cut.service.database.IUserFlowDBService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserFlowInfoDBServiceImpl extends ServiceImpl<IUserFlowInfoDBMapper, DBUserFlowInfo> implements IUserFlowDBService {
    @Override
    public boolean insertIntoData(DBUserFlowInfo info) {
        return this.baseMapper.insert(info) == 1;
    }

    @Override
    public DBUserFlowInfo selectOne(Integer uid, Integer activityId) {
        return this.baseMapper.selectOne(new LambdaQueryWrapper<DBUserFlowInfo>()
                .eq(DBUserFlowInfo::getUid, uid)
                .eq(DBUserFlowInfo::getActivityId, activityId));
    }

    @Override
    public List<DBUserFlowInfo> selectAll(List<Integer> uid) {
        QueryWrapper<DBUserFlowInfo> wrapper = new QueryWrapper<>();
        wrapper.in("uid", uid);
        return this.baseMapper.selectList(wrapper);
    }

    @Override
    public boolean deleteData(Integer uid) {
        return this.baseMapper.deleteById(uid) == 1;
    }

    @Override
    public boolean updateData(DBUserFlowInfo info) {
        QueryWrapper<DBUserFlowInfo> wrapper = new QueryWrapper<>();
        wrapper.in("uid", info.getUid());
        return this.baseMapper.update(info,wrapper) == 1;
    }
}
